import java.util.List;
import java.util.Map;
import java.util.Stack;

public class Leet_1006 {
    public static void main(String[] args) {

    }
    public int clumsy(int N) {
        Stack<Integer> stack = new Stack<>();
        int mod = 1;
        int num = 0;
        stack.push(N);
        for (int i = N-1; i > 0; i--) {
            if (mod == 1){
                stack.push(stack.pop()*i);
                mod++;
                continue;
            }
            if (mod == 2){
                stack.push(stack.pop()/i);
                mod++;
                continue;
            }
            if (mod == 3){
                stack.push(i);
                mod++;
                continue;
            }
            if (mod == 4){
                stack.push(-i);
                mod = 1;
            }
        }
        for (Integer integer : stack)
            num+=integer;
        return num;
    }
}
